/*
 * @Description: 
 * @Author: Zilu
 * @Date: 2021-11-08 22:16:51
 * @Version: 
 * @LastEditTime: 2021-11-08 23:46:22
 * @LastEditors: Zilu
 */

// hotel.c -- 酒店管理程序
#include <stdio.h>
#include "../include/hotel.h"

int menu(void)
{
    int code, status;

    printf("\n%s%s\n", STARS, STARS);
    printf("Enter the num of desired hotel:\n");
    printf("1) Fairfield Arms       2) Hotel Olympic\n");
    printf("3) Chertworthy Plaza    4) The Stockton\n");
    printf("5) quit\n");

    while ((status = scanf("%d", &code)) != 1 || (code < 1 || code >5)){
        if (status != 1)
            scanf("%*s");   //处理非整数输入
        printf("Enter an integer from 1 to 5, please.\n");
    }

    return code;
}

int getNights(void){
    int nights;

    printf("How many nights are needed? ");
    while (scanf("%d", &nights) != 1)
    {
        scanf("%*s");   //处理非整数输入
        printf("Please enter an integer, such as 2.\n");
    }

    return nights;
}

void showPrice(double rate, int nights){
    double total = 0.0;
    double factor = 1.0;
    for (int n = 0; n < nights; n++, factor *= DISCOUNT)
    {
        total += rate * factor;
    }

    printf("The total cost will be $%0.2f.\n", total);
}
